{include file="public/header"}
<div class="pub_wid notice_cont">
    <div class="notice_left bgb lf" id="sourceDetail">
        <h1>实时货源<span>当前位置：<a href="/index/index">主页</a>><a href="/index/source/index">实时货源</a>><a href="#">正文</a></span></h1>
        <h2>{{sourceDetail.province}}丨{{sourceDetail.title}}</h2>
        <ul class="widthauto basics_box">
            <li>服务类别：</li>
            <li>{{sourceDetail.service_name}}</li>
            <li>货物类别：</li>
            <li>{{sourceDetail.trade_name}}</li>
            <li>地区：</li>
            <li>{{sourceDetail.province}}</li>
            <li>发布日期：</li>
            <li>{{sourceDetail.create_time}}</li>
            <li>报名截止日期：</li>
            <li>{{sourceDetail.end_time}}</li>
            <li>投标截止日期：</li>
            <li>{{sourceDetail.end_time}}</li>
        </ul>
        <div class="widthauto detail_cont">
            <div class="widthauto detail_box">
                <div class="detail_lf"><span>招标摘要：</span></div>
                <div class="detail_rg">
                    <ul>
                        <li><span>【项目属地】</span></li>
                        <li>&nbsp;&nbsp;{{sourceDetail.province}}·{{sourceDetail.city}}</li>
                        <li><span>【预算金额】</span></li>
                        <li>&nbsp;&nbsp;{{sourceDetail.budget}}万元</li>
                        <li><span>【项目概况】</span></li>
                        <li>&nbsp;&nbsp;{{sourceDetail.item_about}}</li>
                        <li><span>【投标人资格要求】</span></li>
                        <li>&nbsp;&nbsp;{{sourceDetail.certification_content}}</li>
                        <!--                        <li>&nbsp;&nbsp;2、注册资金500万（含）以上；</li>-->
                        <!--                        <li>&nbsp;&nbsp;3、企业营收规模在3000万/年（含）以上；</li>-->
                        <!--                        <li>&nbsp;&nbsp;4、具有10个以上国内分支机构或办事处并可覆盖10个省份（含）以上的业务范围；</li>-->
                        <!--                        <li>&nbsp;&nbsp;5、从事电子产品运输行业三年及以上，具有服务器或网络产品或监控设备或视讯等产品企业的合作经历；</li>-->
                        <!--                        <li>&nbsp;&nbsp;6、在杭州（或海宁）、深圳（或东莞）或周边机场城市有运营场地，场地面积在 5000平方米以上。</li>-->
                    </ul>
                </div>
            </div>
            <div class="widthauto detail_box">
                <div class="detail_lf"><span>招标内容：</span></div>
                <div class="detail_rg" v-if="sourceDetail.isShow">
                    <ul>
                        <li><span>【招标内容】</span></li>
                        <li>&nbsp;&nbsp;{{sourceDetail.item_content}}</li>
                        <!--                    <li>&nbsp;&nbsp;2、采购设备数量：50套</li>-->
                        <!--                    <li>&nbsp;&nbsp;3、采购设备安装地点：星火区部（奉贤区海湾镇星火农场海兴路479号）</li>-->
                        <!--                    <li>&nbsp;&nbsp;4、行车安全辅组设备的型号、规格、数量详见附件一《行车安全辅组设备报价清单》</li>-->
                        <li><span>【附件】</span></li>
                        <li v-for="(item,index) in accessory_info">&nbsp;&nbsp;{{index+1}}、{{item.name}}<a :href="item.fileUrl"><img src="/static/index/public/images/download.png" /></a></li>
                        <!--                    <li>&nbsp;&nbsp;2、有效的公司营业执照（合一版）（复印件）<a href="#"><img src="/static/index/public/images/download.png" /></a></li>-->
                        <!--                    <li>&nbsp;&nbsp;3、开户许可证<a href="#"><img src="/static/index/public/images/download.png" /></a></li>-->
                        <!--                    <li>&nbsp;&nbsp;4、法人代表授权书或法人代表身份证复印件<a href="#"><img src="/static/index/public/images/download.png" /></a></li>-->
                        <!--                    <li>&nbsp;&nbsp;5、公司简介（注册时间、业务范围、规模、主要客户和业绩等）<a href="#"><img src="/static/index/public/images/download.png" /></a></li>-->
                    </ul>

                    <h3 v-if="isEndTime" class="widthauto" style="color: red">该项目已截止</h3>
                    <h3 v-if="!isEndTime&&isAdd" class="widthauto"><button @click="addItem(sourceDetail.id)">在线报名</button></h3>
                    <h3 v-if="!isEndTime&&!isAdd" class="widthauto">已申请过该项目</h3>
                </div>
                <div class="detail_rg" v-else>
                    <ul class="novip">
                        <li><span>【温馨提示】</span></li>
                        <li>&nbsp;&nbsp;项目详情，仅对VIP会员开放。如需查看详细内容，请升级成为VIP会员，已注册VIP会员请登录后查看。</li>
                        <li>&nbsp;&nbsp;也可添加客服微信详细咨询。</li>
                    </ul>
                    <p>&nbsp;<img src="/static/index/public/images/wechat.jpg" /></p>
                </div>
            </div>
        </div>
    </div>
    {include file="public/right"}
</div>
{include file="public/footer"}

<script>
    var id = "{$id}"
    var sourceDetailVm = new Vue({
        el:'#sourceDetail',
        data:{
            id:id,
            member_id:'',
            sourceDetail:{},
            accessory_info:[],
            isAdd:true,
            isEndTime:false
        },
        methods:{
            getSourceDetail:function () {
                var el = this
                var postData = {
                    "id":el.id
                }
                AjaxPost(postData,'/index/source/getDetail').then((response=>{
                    if(response.result){
                        el.sourceDetail =response.result
                        if(response.result.accessory_info){
                            el.accessory_info = response.result.accessory_info
                        }
                        console.log(response)
                        this.isApplyAdd();
                    }
                })).catch(()=>{
                    window.location.href = '/index/source'
                })
            },
            addItem:function (id) {
                var el =this
                if(!el.sourceDetail.status&&el.sourceDetail.status!=2){
                    $.customToastr('warning','该项目正在审核或者已经截止')
                    return;
                }

                if(el.member_id == ''){
                    $.customToastr('warning','认证之后再申请加入')
                    return;
                }
                if(!localStorage.getItem('member_category')&&localStorage.getItem('member_category') !=2){
                    $.customToastr('warning','只有物流企业可以申请')
                    return;
                }
                postData = {
                    'consignor_item_id':id,
                    'member_id':el.member_id
                }
                AjaxPost(postData,'/index/source/applyConsignorItem').then((response=>{
                    if(response.status==1){
                        $.customToastr('success',response.message)
                    }

                }))
            },
            getTime:function (dateString='') {
                var time = ''
                if(dateString==''){
                    time =  new Date()
                }else {
                    time =  new Date(dateString)
                }
                return time.getTime()
            },
            isApplyAdd:function () {
                var el = this
                postData = {
                    'consignor_item_id':id,
                    'member_id':el.member_id
                }
                if(el.getTime(el.sourceDetail.end_time)<el.getTime()){
                    el.isEndTime = true
                    return;
                }
                AjaxPost(postData,'/index/source/isApplyAdd').then((response=>{
                    if(response.status==1){
                        if(response.result){
                            el.isAdd = false
                        }
                    }
                }))
            }
        },
        mounted(){
            this.$nextTick(function () {
                this.member_id = localStorage.getItem('memberId')
                this.getSourceDetail()

            })
        }
    })
</script>

